
<!DOCTYPE html>
<html lang="en" class="no-js">

    <head>

        <meta charset="utf-8">
        <title>注册</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">

        <!-- CSS -->
        <link rel='stylesheet' href='http://fonts.googleapis.com/css?family=PT+Sans:400,700'>
        <link rel="stylesheet" href="assets/css/reset.css">
        <link rel="stylesheet" href="assets/css/supersized.css">
        <link rel="stylesheet" href="assets/css/style.css">

        <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
            <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->

    </head>

    <body>

        <div class="page-container">
            <h1>注册</h1>
             <div>
                <input type="text" id="username" name="username"  placeholder="Username">
                <br>
                <input type="password" id="password" name="password"  placeholder="Password">  
                <br>            
                <button type="submit" onclick="UserRegister()" >注册</button> 
                <br>
                <div class="error"><span>+</span></div>
            </div>
            <form>
            </form>
        </div>

        <!-- Javascript -->
        <script src="assets/js/jquery-1.8.2.min.js"></script>
        <script src="assets/js/supersized.3.2.7.min.js"></script>
        <script src="assets/js/supersized-init.js"></script>
        <script src="assets/js/scripts.js"></script>
        <script>
        function UserRegister(){
    		var username = document.getElementById('username');
    		var password = document.getElementById('password');
    		var re = "username="+username.value+"&password="+password.value;
    		var url = encodeURI(re);
    		xhr = new XMLHttpRequest();
    		xhr.open('POST', 'UserRegister', true);
    		xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    		xhr.send(url);
    		xhr.onreadystatechange = function() {
    			if (this.readyState != 4)
    				return;
    			
    			if (this.responseText != '[]')
    			{
    				var json=JSON.parse( this.responseText );
    				if(json.result){
    					//用户密码正确后跳转
    				    var form=document.forms[0];
    				    form.action="GotoUserQueryRe";
    				    form.submit();
    				}
    				else{
    					alert("用户名已经被注册！");
    				}
    				
    			}
    	    }
        }
        </script> 
    </body>

</html>
